package com.ciwong.epaper.modules.viedoexplantion.util;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.ciwong.epaper.application.EpaperConstant;
import com.ciwong.epaper.modules.cordva.CordovaWebViewTestActivity;
import com.ciwong.epaper.modules.cordva.VideoExplainOnlineAnswerResultActivity;
import com.ciwong.epaper.modules.cordva.html.NewVideoExplationActivity;
import com.ciwong.epaper.modules.epaper.bean.Answer;
import com.ciwong.epaper.modules.epaper.bean.EpaperInfo;
import com.ciwong.epaper.modules.epaper.bean.Module;
import com.ciwong.epaper.modules.epaper.ui.AiSpokenActivity;
import com.ciwong.epaper.modules.epaper.ui.ListenSpeakVideoActivity;
import com.ciwong.epaper.modules.epaper.ui.html.AiHtmlActivity;
import com.ciwong.epaper.modules.evaluate.ui.PhoneticSymbolActivity;
import com.ciwong.epaper.modules.evaluate.ui.SymbolVideoActivity;
import com.ciwong.epaper.modules.msg.bean.Symbols;
import com.ciwong.epaper.modules.viedoexplantion.ViedoExplationActivity;
import com.ciwong.epaper.modules.viedoexplantion.player.KHBVideoPlayActivity;
import com.ciwong.epaper.util.IntentFlag;
import com.ciwong.epaper.util.download.DownLoadInfo;
import com.ciwong.mobilelib.utils.BaseJumpManager;

import java.io.Serializable;
import java.util.List;

/**
 * Created by young on 2016/7/6.
 * 视频解析模块跳转类
 */
public class ViedoJumpManager extends BaseJumpManager {
    /**
     * 跳转到视频解析界面
     *
     * @param goBackId
     * @param context
     * @param {@link   IntentValue.JumpToJoinClassType}
     */
    public static void jumpToViedoExplationActivity(int goBackId, Activity context) {
        Intent intent = getBaseIntent(goBackId, context,
                ViedoExplationActivity.class);
        context.startActivity(intent);

    }

    /* public static void jumpToHtmlActivity(int goBackId, Activity context) {
         Intent intent = getBaseIntent(goBackId, context,
                 HtmlActivity.class);
         context.startActivity(intent);
     }*/
    //线上作答 视频讲解
    public static void jumpToCordovaWebViewTestActivity(int goBackId, Activity context, int type, String workId, DownLoadInfo downLoadInfo, Module module, int position, Answer answer, String doWorkId, String comment, String ServiceTitle, int pageType, int serviceId, List<EpaperInfo.Server> serverList, String classId, int requestCode) {

        Intent intent = getBaseIntent(goBackId, context, CordovaWebViewTestActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_TYPE, type);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_ID, workId);
        intent.putExtra(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, downLoadInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_DO_WORK_ID, doWorkId);
        intent.putExtra(IntentFlag.INTENT_FLAG_ANSWER, answer);
        intent.putExtra(IntentFlag.INTENT_FLAG_TEACHER_COMMENT, comment);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_TITLE, ServiceTitle);
        intent.putExtra(IntentFlag.INTENT_FLAG_H5_PAGE_TYPE_SOURCE, pageType);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ_LIST, (Serializable) serverList);
        intent.putExtra(IntentFlag.INTENT_FLAG_CLASS_ID, classId);
        context.startActivityForResult(intent, requestCode);
    }

    //线上作答
    public static void jumpToOnLinePaperActivity(int goBackId, android.app.Fragment fragment, int type, String workId, DownLoadInfo downLoadInfo, Module module, int position, Answer answer, String doWorkId, String comment, String ServiceTitle, int pageType, int serviceId, List<EpaperInfo.Server> serverList, String classId, int requestCode) {

        Intent intent = getBaseIntent(goBackId, fragment.getActivity(), CordovaWebViewTestActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_TYPE, type);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_ID, workId);
        intent.putExtra(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, downLoadInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_DO_WORK_ID, doWorkId);
        intent.putExtra(IntentFlag.INTENT_FLAG_ANSWER, answer);
        intent.putExtra(IntentFlag.INTENT_FLAG_TEACHER_COMMENT, comment);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_TITLE, ServiceTitle);
        intent.putExtra(IntentFlag.INTENT_FLAG_H5_PAGE_TYPE_SOURCE, pageType);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ_LIST, (Serializable) serverList);
        intent.putExtra(IntentFlag.INTENT_FLAG_CLASS_ID, classId);
        fragment.startActivityForResult(intent, requestCode);
    }

    //跳转到老的视频讲解资源和线上作答 错题本页面
    public static void jumpToCordovaWebViewTestcAtivity(int goBackId, Activity context, int type, String workId, DownLoadInfo downLoadInfo, Module module, int position, Answer answer, String doWorkId, String comment, String ServiceTitle, int pageType, int serviceId, List<EpaperInfo.Server> serverList, EpaperInfo epaperInfo) {

        Intent intent = getBaseIntent(goBackId, context, CordovaWebViewTestActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_TYPE, type);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_ID, workId);
        intent.putExtra(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, downLoadInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_DO_WORK_ID, doWorkId);
        intent.putExtra(IntentFlag.INTENT_FLAG_ANSWER, answer);
        intent.putExtra(IntentFlag.INTENT_FLAG_TEACHER_COMMENT, comment);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_TITLE, ServiceTitle);
        intent.putExtra(IntentFlag.INTENT_FLAG_H5_PAGE_TYPE_SOURCE, pageType);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ_LIST, (Serializable) serverList);
        intent.putExtra(IntentFlag.INTENT_FLAG_EPAPER_INFO, epaperInfo);
        context.startActivity(intent);
    }


    //跳转到新的视频讲解资源和线上作答 错题本页面
    public static void jumpToNewVideoExplationActivity(int goBackId, Activity context, DownLoadInfo downLoadInfo, Module module, int position, String comment, String ServiceTitle, int serviceId, List<EpaperInfo.Server> serverList, EpaperInfo epaperInfo, String classId) {

        Intent intent = getBaseIntent(goBackId, context, NewVideoExplationActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, downLoadInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_TEACHER_COMMENT, comment);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_TITLE, ServiceTitle);
        if (serviceId >= 0)
            intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ_LIST, (Serializable) serverList);
        intent.putExtra(IntentFlag.INTENT_FLAG_EPAPER_INFO, epaperInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_CLASS_ID, classId);
        context.startActivity(intent);
    }

    //扫一扫章节时可以跳状视屏奖金额i
    public static void jumpToNewVideoExplationActivityPreView(int goBackId, Activity context, DownLoadInfo downLoadInfo, Module module, int position, String comment, String ServiceTitle, int serviceId, boolean isPreView, EpaperInfo epaperInfo) {

        Intent intent = getBaseIntent(goBackId, context, NewVideoExplationActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, downLoadInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_TEACHER_COMMENT, comment);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_TITLE, ServiceTitle);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_PRE_VIEW, isPreView);
        intent.putExtra(IntentFlag.INTENT_FLAG_EPAPER_INFO, epaperInfo);
        context.startActivity(intent);
    }

    public static void jumpToResultActivity(int goBackId, Activity context, int requestCode, int type, String workId, DownLoadInfo downLoadInfo, Module module, int position, String doWorkId, String jsonSource, int totalTime, String score, int pageType, int serviceId, String classId) {
        Intent intent = getBaseIntent(goBackId, context, VideoExplainOnlineAnswerResultActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_TYPE, type);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_ID, workId);
        intent.putExtra(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, downLoadInfo);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_DO_WORK_ID, doWorkId);
        intent.putExtra(IntentFlag.INTENT_FLAG_STR, jsonSource);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_TIME, totalTime);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_SCORE, score);
        intent.putExtra(IntentFlag.INTENT_FLAG_H5_PAGE_TYPE_SOURCE, pageType);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_CLASS_ID, classId);
        context.startActivityForResult(intent, requestCode);
    }

    /**
     * @param goBackId
     * @param context
     * @param requestCode
     * @param type
     * @param workId
     * @param module
     * @param position
     * @param doWorkId
     * @param resubmit           重新提交
     * @param totalTime
     * @param score
     * @param pageType
     * @param serviceId
     * @param classId
     * @param submitFailedAnswer
     */
    public static void jumpToResultActivityAgain(int goBackId, Activity context, int requestCode, int type, String workId, Module module, int position, String doWorkId, boolean resubmit, int totalTime, String score, int pageType, int serviceId, String classId, Answer submitFailedAnswer) {
        Intent intent = getBaseIntent(goBackId, context, VideoExplainOnlineAnswerResultActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_TYPE, type);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_ID, workId);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, module);
        intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
        intent.putExtra(IntentFlag.INTENT_FLAG_DO_WORK_ID, doWorkId);
        intent.putExtra(IntentFlag.INTENT_FLAG_RESUBMIT, resubmit);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_TIME, totalTime);
        intent.putExtra(IntentFlag.INTENT_FLAG_WORK_SCORE, score);
        intent.putExtra(IntentFlag.INTENT_FLAG_H5_PAGE_TYPE_SOURCE, pageType);
        intent.putExtra(IntentFlag.INTENT_FLAG_SERVICE_ID, serviceId);
        intent.putExtra(IntentFlag.INTENT_FLAG_CLASS_ID, classId);
        intent.putExtra(IntentFlag.INTENT_FLAG_ANSWER, submitFailedAnswer);
        context.startActivityForResult(intent, requestCode);
    }

    /**
     * 跳转到音标界面
     * @param goBackId
     * @param Context
     */
    public static void jumpToPhoneticSymbol(int goBackId, Activity Context) {
        Intent intent = getBaseIntent(goBackId, Context, PhoneticSymbolActivity.class);
        Context.startActivity(intent);
    }


    /**
     * 跳转到音标界面
     * @param goBackId
     * @param Context
     */
    public static void jumpToAiSpokenActivity(int goBackId, Activity Context) {
        Intent intent = getBaseIntent(goBackId, Context, AiHtmlActivity.class);
        Context.startActivity(intent);
    }


    /**
     *
     * @param goBackId
     * @param Context
     * @param symbols
     */
    public static void jumpToSymbolVideo(int goBackId, Activity Context, Symbols symbols) {
        Intent intent = getBaseIntent(goBackId, Context, SymbolVideoActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_SYMBOL,symbols);
        Context.startActivity(intent);
    }

    /**
     * 跳转到添加书籍
     *
     * @param goBackId    返回按钮的文字id
     * @param act         启动activity
     * @param requestCode 返回码
     */
    public static void jumpToListenSpeakVideo(int goBackId, Activity act, int requestCode, String vuid, int playType, String recorderPath, String title, String bigStem)//
    {
        Intent intent = getBaseIntent(goBackId, act, ListenSpeakVideoActivity.class);
        Bundle mBundle = new Bundle();
//        mBundle.putInt(PlayerParams.KEY_PLAY_MODE, PlayerParams.VALUE_PLAYER_VOD);
        mBundle.putInt(ListenSpeakVideoActivity.KEY_PLAY_TYPE, playType);
        if (playType == EpaperConstant.LISTEN_SPEAK_PLAY_TYPE_NEED_RECORD) {
            mBundle.putString(ListenSpeakVideoActivity.KEY_RECORDER_PATH, recorderPath);

        } else if (playType == EpaperConstant.LISTEN_SPEAK_PLAY_TYPE_NO_NEED_RECORD) {
        }
        mBundle.putString(EpaperConstant.KEY_PLAY_VUID,vuid);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, mBundle);
        intent.putExtra(ListenSpeakVideoActivity.KEY_TITLE, title);
        intent.putExtra(ListenSpeakVideoActivity.KEY_QUE_STEM, bigStem);

        act.startActivityForResult(intent, requestCode);
    }

    /**
     * 跳转到视频界面
     *
     * @param goBackId
     * @param context
     * @param
     */
    public static void jumpToKHBVideoPlayActivity(int requesttCode, int goBackId, Activity context, String url) {
        Intent intent = getBaseIntent(goBackId, context,
                KHBVideoPlayActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, url);
        context.startActivityForResult(intent, requesttCode);
    }
}
